/*
 * 项目名称:platform-plus
 * 类名称:CustRecordServiceImpl.java
 * 包名称:com.platform.modules.cust.service.impl
 *
 * 修改履历:
 *     日期                       修正者        主要内容
 *     2020-10-10 14:34:32        klwu     初版做成
 *
 * Copyright (c) 2019-2019 klwu
 */
package com.platform.modules.custmoer.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.platform.common.utils.Query;
import com.platform.modules.custmoer.dao.CustRecordDao;
import com.platform.modules.custmoer.entity.CustRecordEntity;
import com.platform.modules.custmoer.service.CustRecordService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * Service实现类
 *
 * @author klwu
 * @date 2020-10-10 14:34:32
 */
@Service("custRecordService")
public class CustRecordServiceImpl extends ServiceImpl<CustRecordDao, CustRecordEntity> implements CustRecordService {

    @Override
    public List<CustRecordEntity> queryAll(Map<String, Object> params) {
        return baseMapper.queryAll(params);
    }

    @Override
    public Page queryPage(Map<String, Object> params) {
        //排序
        params.put("sidx", "T.CREATE_TIME");
        params.put("asc", false);
        Page<CustRecordEntity> page = new Query<CustRecordEntity>(params).getPage();
        return page.setRecords(baseMapper.selectCustRecordPage(page, params));
    }

    @Override
    public boolean add(CustRecordEntity custRecord) {
        return this.save(custRecord);
    }

    @Override
    public boolean update(CustRecordEntity custRecord) {
        return this.updateById(custRecord);
    }

    @Override
    public boolean delete(String id) {
        return this.removeById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean deleteBatch(String[] ids) {
        return this.removeByIds(Arrays.asList(ids));
    }

    public double recordTotal(){
        return baseMapper.recordTotal();
    }
    public double prerecordTotal(){
        return baseMapper.prerecordTotal();
    }
}
